<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

</head>
<body>
<table border="1">
    <tr>
        <th>用户编号</th>
        <th>用户名</th>
        <th>密码</th>
        <th>&nbsp&nbsp</th>
        <th>&nbsp&nbsp</th>
    </tr>
    <tr th:each="user:${users}">
        <td th:text="${user.id}"></td>
        <td th:text="${user.username}"></td>
        <td th:text="${user.password}"></td>
        <td><a th:href="@{'/user/edit/' + ${user.id}}" target="right">修改</a></td>
        <td><a href="#" th:attr="data-userid=${user.id}" th:onclick="confirmDelete(this.getAttribute('data-userid'))">
            删除</a></td>
    </tr>
</table>
<script th:inline="javascript">
    function confirmDelete(userId) {
        var result = confirm("Are you sure you want to delete this user?");
        if (result) {
            window.location.href = '/user/delete/' + userId;
        } else {
        }
    }
</script>

</body>
</html>